package com.study.a07Test;

import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.InetAddress;
import java.net.Socket;

public class Client {
    public static void main(String[] args) throws IOException {

        Socket socket= new Socket("127.0.0.1",9000);

        //写出数据
        String str="hello server";
        OutputStream os=socket.getOutputStream();
        os.write(str.getBytes());

        //结束标记
        socket.shutdownOutput();
        //接受回写数据
        InputStreamReader isr=new InputStreamReader(socket.getInputStream());
        int b;
        while((b=isr.read())!=-1){
            System.out.print((char)b);
        }

        //关闭资源
        os.close();
        socket.close();

    }
}
